package com.kky.pp.adapter

import android.app.Activity
import android.widget.ImageView
import android.widget.TextView
import com.custom.base.base.BaseRecyclerAdapter
import com.custom.base.view.SuperViewHolder
import com.kky.pp.R
import com.kky.pp.base.GenderPreferListBean
import com.kky.pp.util.GlideUtil

class GenderPreferAdapter(
    var ctx:Activity,
    listModel: ArrayList<GenderPreferListBean>,
    var listener: OnListener
) : BaseRecyclerAdapter<GenderPreferListBean>(listModel, ctx) {
    var allData = arrayListOf<GenderPreferListBean>()
    override val layoutId: Int get() = R.layout.item_gender_prefer
    override fun onBindItemHolder(position: Int, holder: SuperViewHolder, model: GenderPreferListBean, payloads: List<Any>?) {
        val itemLogo = holder.getView<ImageView>(R.id.imgViewItemGenderPrefer)
        val itemText = holder.getView<TextView>(R.id.txtItemGenderPrefer)
        GlideUtil.setImageView(model.iconUrl, itemLogo, placeholderImageId = 0)

        holder.itemView.setBackgroundResource(if (model.selected==0) R.drawable.shape_283040_radius_25_10 else R.drawable.shape_4634a9_f63669_radius_25_10)
        itemText.text=model.value
        holder.setOnClickListener {
            listener.onListener(this@GenderPreferAdapter,position)
        }

    }
    interface OnListener{
        fun onListener(adapter: GenderPreferAdapter, position: Int)
    }
}